<?php
	echo $html->link(__("Add new plan"),array("action"=>"add"),array('class'=>'add_button'));
?>

<?php
	function showPlanDurationPeriod($plan)
	{
		$durationOptions = cri("Plan")->getFieldProperty('duration_period','options');

		if($plan['Plan']['duration_period'])
		{
			$label = $plan['Plan']['duration_number'].' '.$durationOptions[$plan['Plan']['duration_period']];
		}else
		{
			$label = $durationOptions[""];
		}
		return $label;
	}
?>
<?php if(count($plans) == 0) {?>
	<h4><?php echo __("No plans present.")?> </h4>
<?php }else{ ?>
	<?php 
		$index->setData($plans,'Plan');
		$fields = cri("Plan")->getFields("group",'add');
		$fields = array_combine($fields,$fields);
		$fields['duration_period'] = array('duration_period_'=>cri("Plan")->getFieldProperty("duration_period",'label'));
		unset($fields['duration_number'],$fields['description'],$fields['limit_images'],$fields['images'],$fields['allow_gallery'],$fields['allow_multiple_categories']);
		unset($fields['enable_offers'],$fields['active_offers_limit'],$fields['enable_promotions'],$fields['active_promotions_limit'],$fields['limit_events'],$fields['allowed_events_limit']);
		//$fields['duration_period']
        $fields['is_default'] = array("is_default"=>__("Default"));
        $fields['featured'] = array("featured"=>__("Featured"));
        $fields['payment_type'] = array("payment_type"=>__("Payment type"));
       // pr($fields);
		$fields = array_values($fields);
		$index->showFields($fields);
		$index->sortablefields($fields);
		$index->addColumn('duration_period_','showPlanDurationPeriod');
		$index->setPaginateSeparator(' ');
		$index->setAction(__("Edit"),'/admin/paid_listings/plans/edit/:Plan.id');
		$index->setAction(__("Delete"),'/admin/paid_listings/plans/delete/:Plan.id',array(),__("Are you sure you want to delete this plan?"));
		echo $index->display($plans);
	?>
<?php } ?>

